<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    var strStr = function(haystack, needle) {
      for(let i=0; i< haystack.length; i++) {
          let str1,str2
          for(let j=0; j< needle.length; j++){
              str1 = haystack.slice(i, i+j+1)
              str2 = needle.slice(0, j+1)
              if(str1 !== str2) break

          }
          console.log(str1, str2)
          if(str1 === str2 && str2 === needle) return i
      }
      return -1
    };
    console.log(strStr('hello', 'll'))
  </script>
</body>
</html>